home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / screen.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  2KB  |  55 lines

  1. #include "screen.h"
  2.  
  3. ScreenSet* pScreenSet;
  4.  
  5. // This function initialise system not for all possible modes.
  6. // To use another regime or mode - add corresponding block
  7. ScreenSet::ScreenSet(int gdriver, int gmode)
  8.     {
  9.     icon_types[0] = loc(0, 0);
  10.     icon_types[1] = loc(7, 3);            // TEXT size of icons
  11.     icon_types[2] = loc(3, 1);
  12.     icon_types[3] = loc(15, 5);
  13.  
  14.     int maxX = getmaxx() + 1;
  15.     int maxY = getmaxy() + 1;
  16.  
  17.     cell_height = maxY / 25;
  18.     if(maxX == 640)             // To use system with low resolution add
  19.     log2cell_width = 3;     // corresponding operator.
  20.     else
  21.         log2cell_width = 4;
  22.  
  23.     cell_width  = 1 << log2cell_width;
  24.  
  25.     ICON_PIXELS_1 = loc(cell_width * 7, cell_height * 3);
  26.     ICON_PIXELS_2 = loc(cell_width * 3, cell_height);
  27.     ICON_PIXELS_3 = loc(cell_width * 15, cell_height * 5);
  28.  
  29.     standart_width =   cell_width;  // Char dimentions, not connected with
  30.     standart_height =  cell_width;  // cells. Used as default for screen
  31.     sub_interval    = cell_width + 4;  // output.
  32.  
  33.     g_driver = gdriver; g_mode = gmode;
  34.     }
  35. //////////////////////////
  36. int* ScreenSet::get_cells(rect cur_rect)
  37.     {
  38.     int* cells = new int[25 * 80];
  39.     int cells_num = 0;
  40.     for(int y = cur_rect.origin.Y; y < cur_rect.corner.Y;
  41.         y += pScreenSet->cell_height)
  42.     for(int x = cur_rect.origin.X; x < cur_rect.corner.X;
  43.         x += pScreenSet->cell_width)
  44.         {
  45.         cells[cells_num] = y / pScreenSet->cell_height * 80
  46.             + (x >> pScreenSet->log2cell_width);
  47.         cells_num++;
  48.         }
  49.  
  50.     cells[cells_num] = -1;
  51.  
  52.     return cells;
  53.     }
  54. //////////////////////////
  55.